package site.xuqing.androidbase.net.util;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.logging.HttpLoggingInterceptor;
import site.xuqing.androidbase.util.LogUtil;

/**
 * @author xuqing
 * @Description TODO
 * @createTime 2021年12月13日 14:10:57
 */
public class InterceptorUtil {
    public static HttpLoggingInterceptor logInterceptor() {
        return new HttpLoggingInterceptor(LogUtil :: logNet).setLevel(HttpLoggingInterceptor.Level.BODY);
    }
    
    public static Interceptor headerInterceptor() {
        return chain -> {
            Request request = chain.request().newBuilder().
                addHeader("Content-Type", "application/json;charSet=UTF-8").build();
            return chain.proceed(request);
        };
    }
}
